Failover

class Failover<T>

JS/TS-friendly facade over com.sorinirmies.arrow.resiliencekit.Failover -- tries a prioritized list of named providers, falling through to the next one when the current one's circuit is open or it fails outright.

The Kotlin failover { provider(...) } DSL builder isn't exposed directly (it's a suspend, receiver-style builder lambda, which doesn't bridge to JS/TS the same way a plain callback does); pass an array of FailoverProviderSpec instead.

import { Failover, FailoverProviderSpec } from "arrow-resilience-kit";

const transport = await Failover.create([
new FailoverProviderSpec("websocket", () => connectWebSocket()),
new FailoverProviderSpec("mqtt", () => connectMqtt()),
]);
const connection = await transport.execute();

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun execute(): Promise<T>

Tries each provider in priority order, resolving with the first one that succeeds.

Link copied to clipboard

Names of all configured providers, in priority order.

Link copied to clipboard
fun startHealthProbing(intervalMillis: Double): () -> Unit

Starts actively probing every currently-open provider every intervalMillis, instead of waiting for real traffic to pass through execute and incidentally test them. Call the returned function to stop probing.

Link copied to clipboard

Current circuit-breaker state ("Closed", "Open", "HalfOpen") of the named provider, or undefined.

Link copied to clipboard

Per-provider invocation statistics, in priority order.